﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RangeValidator2.MaximumValue = DateTime.Now.ToShortDateString();
                RangeValidator3.MaximumValue = DateTime.Now.ToShortDateString();
            }
        }

        protected void btnCommit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Literal1.Text = $"注册成功<br/>" +
                    $"<a href='WebForm2.aspx?username={tbxUserName.Text}&password={tbxPassword.Text}'>点击登录</a>";
            }
        }

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value.Equals("admin",StringComparison.OrdinalIgnoreCase))
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
    }
}